/*
 * Copyright (c) 2011 Robert Kirchgessner <rkirchge@gmail.com>
 *                    Carlo Pascoe <carlo.pascoe@gmail.com>
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

#pragma once
#ifndef _MOTIFSEARCH_H_
#define _MOTIFSEARCH_H_

#include <stdio.h>
#include <stdint.h>
#include "motif.h"
#include "hashgraph.h"

struct motif_list
{
    double score;
    uint32_t *hg_node_map;
    uint32_t *hgq_node_map;
    struct motif_list *next;
};

struct motif_list_head
{
    struct motif_list *next;
    uint32_t list_cnt;
};

/**
 * Searches a graph for a set of specific motif patterns
 * @param g Input graph to search
 * @param motifs Array of graphs (motif graphs as inputs) to search for
 * @param count The number of patterns in the pattern array
 * @param matches The number of matches for the corresponding pattern entry
 */
//void motif_search_template(struct graph *g, double threshold, struct graph *motifs, uint32_t count, uint32_t *matches);

/**
 * Searches a graph for highly occuring patterns -- does not utilize a template
 * @param g Input graph to search
 * @param threshold Minimum distance
 * @param k The feature size
 * @return The number of matches for the corresponding pattern entry
 */
uint32_t motif_search_auto(struct hash_graph *hg, uint32_t threshold, uint32_t k, struct motif_pattern *mp);

/**
 * Generate a list of motif template graphs from a graph6 format file
 */
void motif_template_generate(char *g6str, uint32_t *size, struct graph *motif);

void hash_func(struct subgraph *sg, hash_type *hash, uint32_t feature_size);

void free_motif_list(struct motif_list_head * mlh);

void motif_align(struct hash_graph *hg, struct hash_graph *hgq, struct motif_list_head *ml, uint32_t threshold, uint32_t feature_size);

void calculateZSCORE(int subgraphCounter, uint32_t rand, int motifs, double *mean_inrand, double *var_inrand, double *total_inreal, char *path);

#endif /*_MOTIFSEARCH_H_*/

